package com.bh.extend.mapper;

import com.bh.common.basemapper.RootMapper;
import com.bh.extend.domain.JcOrderBarcode;
import com.bh.extend.vo.JcOrderBarcodePrintVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 条码与商品对应Mapper接口
 *
 * @author slx
 * @date 2023-03-27
 */
@Mapper
public interface JcOrderBarcodeMapper extends RootMapper<JcOrderBarcode> {

    /**
     * 查询条码与商品对应列表
     *
     * @param jcOrderBarcode 条码与商品对应
     * @return 条码与商品对应集合
     */
    public List<JcOrderBarcode> selectJcOrderBarcodeList(JcOrderBarcode jcOrderBarcode);



    /**
     * 查询条码与商品对应列表
     * @param ledId
     * @return
     */
    public List<JcOrderBarcode> selectJcOrderBarcodeListByLedId(@Param("ledOrderId") Long ledOrderId);

    /**
     * 查询条码与商品对应列表
     * @param shipmentId
     * @return
     */
    public List<JcOrderBarcode> selectUnloadJcOrderBarcodeList(@Param("shipmentId") Long shipmentId, @Param("ledOrderId") Long ledOrderId);

    /**
     * 查询条码与商品对应列表
     * @param orderId
     * @return
     */
    public List<JcOrderBarcode> selectJcOrderBarcodeListByOrderId(@Param("orderId") Long orderId);



    public List<JcOrderBarcodePrintVo> selectJcOrderBarcodePrintVoListByOrderId(@Param("orderId") Long orderId);
    /**
     *
     * @param shipmentId
     * @return
     */
    @MapKey("led_order_id")
    public Map<String, Map<String, Long>> selectLedOrderIdsByShipmentId(@Param("shipmentId") Long shipmentId);


    /**
     * 查询所有卸货和未卸货的分段订单ID
     * @param shipmentId
     * @return
     */
    public List<String> selectUnloadLedIdsByShipmentId(@Param("shipmentId") Long shipmentId, @Param("orgId") Long orgId);

    /**
     * 查询所有卸货和未卸货的分段订单ID
     * @param shipmentId
     * @return
     */
    public Integer selectUnloadLedNumByShipmentId(@Param("shipmentId") Long shipmentId, @Param("orgId") Long orgId);


    /**
     * 查询未保存卸货完成的分段订单ID
     * @param shipmentId
     * @return
     */
    @MapKey("led_order_id")
    public Map<String, Map<String, Long>> selectUnloadLedOrderIdsByShipmentId(@Param("shipmentId") Long shipmentId, @Param("ledOrderIds") String ledOrderIds);


    /**
     * 查询运单的某一个站点卸货未完成的分段订单ID
     * @param shipmentId
     * @return
     */
    public List<String> selectNoUnloadLedIdsByShipmentIdAndOrgId(@Param("shipmentId") Long shipmentId, @Param("orgId") Long orgId);

    /**
     * 查询运单所有未卸货完成的分段订单ID
     * @param shipmentId
     * @return
     */
    public List<String> selectNoUnloadLedIdsByShipmentId(@Param("shipmentId") Long shipmentId);


    /**
     * 查询运单的某一个站点已经卸货但未保存的分段订单ID
     * @param shipmentId
     * @return
     */
    public List<String> selectNoSaveUnloadLedIdsByShipmentIdAndOrgId(@Param("shipmentId") Long shipmentId, @Param("orgId") Long orgId);

    /**
     * 查询未保存但卸货完成的分段订单ID
     * @param shipmentId
     * @return
     */
    @MapKey("led_order_id")
    public Map<String, Map<String, Long>> selectNoSaveUnloadLedOrderIdsByShipmentId(@Param("shipmentId") Long shipmentId, @Param("ledOrderIds") String ledOrderIds);

    /**
     *
     * @param shipmentId
     * @return
     */
    @MapKey("led_order_id")
    public Map<String, Map<String, Long>> selectPreSendLedOrderIdsBySendId(@Param("sendId") Long sendId);


    /**
     *
     * @param
     * @return
     */
    public Integer countPreSendLedNumbersByLedId(@Param("ledOrderId") Long ledOrderId);

    /**
     *
     * @param shipmentId
     * @return
     */
    public List<JcOrderBarcode> selectJcOrderBarcodeListByShipmentId(@Param("shipmentId") Long shipmentId);

    /**
     *
     * @param shipmentId
     * @return
     */
    public JcOrderBarcode selectJcOrderBarcodeByCode(@Param("code") String code);

    /**
     * 查询条码与商品对应列表
     * @param start
     * @param end
     * @return
     */
    public List<JcOrderBarcode> selectJcOrderBarcode(@Param("ledOrderId") Long ledOrderId, @Param("start") String start, @Param("end") String end);

    /**
     *
     * @param productCode
     * @return
     */
    int removeJcOrderBarcodePack(@Param("productCode") String productCode);

    /**
     *
     * @param productCode
     * @return
     */
    public int removeJcOrderBarcodeSend(@Param("productCode") String productCode);

    /**
     * 新增条码与商品对应
     *
     * @param list 条码与商品对应
     * @return 结果
     */
    public int batchInsertJcOrderBarcode(List<JcOrderBarcode> list);


    /**
     * 基于 orderId 的删除方法
     */
    public int deleteByOrderIds(@Param("orderIds") List<Long> orderIds);
}
